package{
	
	import asunit.textui.TestRunner;
	
	import com.asnike.P.bejeweled.*;
	import com.asnike.net.*;
	import com.asnike.util.*;
	
	import flash.display.*;
	
	import tests.*;

	[SWF( width=400, height=400, frameRate=60 )]
	public class Main extends Sprite{
	
		include 'embed/embed.as';
		
		static public var resources:Array = [];
		public function Main():void{
			loadResources();
			
			stage.scaleMode = StageScaleMode.NO_SCALE;
		}
		private function loadResources():void{
			var i:int, j:int, xml:XML;
			
			ASLoader.loadImage( 'remote/jewels.png', function( $data:Array ):void{
				xml = 
				<data>
					<image x="0" y="0" width="48" height="48" />
					<image x="48" y="0" width="48" height="48" />
					<image x="0" y="48" width="48" height="48" />
					<image x="48" y="48" width="48" height="48" />
					<image x="0" y="96" width="48" height="48" />
					<image x="48" y="96" width="48" height="48" />
				</data>;
				
				resources = ASImageCropper.getImages( $data[0], xml );
//				test();
				testGameView();
			} );
		}
		private function test():void{
			var testRunner:TestRunner;
			
			testRunner = new TestRunner;
			addChild( testRunner );
			testRunner.start( AllTests, null, TestRunner.SHOW_TRACE );
			
		}
		private function testGameView():void{
			var control:GameControl, model:GameModel, view:GameView;
			
			model = new GameModel;
			view = new GameView;
			
			addChild( view );
			
			control = new GameControl( model, view );
			control.setJewelSize( 6, 6 );
			control.gameReady();
		}
	}
}
